/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.personInfo;

import model.Constants;

/**
 * Contains contact information about some person.
 * @author Dmitri Paziy
 */
public class Contacts implements Cloneable{
    private String phoneNumber;
    private String address;

    public Contacts(String phoneNumber, String address) {
        this.phoneNumber = phoneNumber;
        this.address = address;
    }

    /**
     * Getter of address, may return <i>null</i> if null value was set.
     * @return Address
     */
    public String getAddress() {
        return address;
    }

    /**
     * Setter of address, <i>null</i> may be passed.
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * Getter of phone number, may return <i>null</i> if null value was set.
     * @return Phone number
     */
    public String getPhoneNumber() {
        return phoneNumber;
    }

    /**
     * Setter of phone number, <i>null</i> may be passed.
     */
    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();
        
        builder.append("Phone number: ");
        if (phoneNumber != null) {
            builder.append(phoneNumber);
        } else {
            builder.append("none");
        }
        builder.append(Constants.LINE_SEPARATOR);
        
        builder.append("Address: ");
        if (address != null) {
            builder.append(address);
        } else {
            builder.append("none");
        }
        builder.append(Constants.LINE_SEPARATOR);
        
        return builder.toString();
    }

    @Override
    public Object clone() {
        return new Contacts(phoneNumber, address);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Contacts other = (Contacts) obj;
        if ((this.phoneNumber == null) ? (other.phoneNumber != null) : !this.phoneNumber.equals(other.phoneNumber)) {
            return false;
        }
        if ((this.address == null) ? (other.address != null) : !this.address.equals(other.address)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 41 * hash + (this.phoneNumber != null ? this.phoneNumber.hashCode() : 0);
        hash = 41 * hash + (this.address != null ? this.address.hashCode() : 0);
        return hash;
    }
}
